package com.example.springboot.mapper;

import com.example.springboot.pojo.Worker;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface WorkerMapper {

    //查询所有工作人员
    @Select("select * from worker")
    List<Worker> getAllWorker();

    @Select("select * from worker where worker_id=#{workerId}")
    Worker findByWorkerId(String workerId);

    @Insert("insert into worker(worker_id,name,id,phone_number,password,department,email)" +
            " values(#{workerId},#{name},#{id},#{phoneNumber},#{password},#{department},#{email})")
    void addWorker(String workerId, String name, String password, String id, String phoneNumber, String department,String email);

    @Update("update worker set name=#{name},id=#{id},phone_number=#{phoneNumber},department=#{department},email=#{email} where worker_id=#{workerId}")
    void updateWorker(String workerId, String name, String id, String phoneNumber,String department,String email);

    @Delete("delete from worker where worker_id=#{workerId}")
    void deleteWorker(String workerId);

    @Select("select * from worker where department='维修部'")
    Worker[] findRepairman();

    @Update("update worker set password=#{password} where email=#{email}")
    void updatePassword(String email, String password);

    @Select("select * from worker where email=#{email}")
    Worker findByEmail(String email);
}
